package com.book.dacnhantam.data;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import java.util.ArrayList;
import java.util.List;

public class DatabaseHelper extends SQLiteOpenHelper
{
  protected SQLiteDatabase db;
  private Context mContext;

  public DatabaseHelper(Context paramContext)
  {
    super(paramContext, "thienlong_db", null, 1);
    this.mContext = paramContext;
    this.db = getWritableDatabase();
  }

  public List<Bookmark> getBookmarkList()
  {
    ArrayList localArrayList = new ArrayList();
    SQLiteDatabase localSQLiteDatabase = this.db;
    String[] arrayOfString = new String[4];
    arrayOfString[0] = "id";
    arrayOfString[1] = "bookmark_name";
    arrayOfString[2] = "chapter_id";
    arrayOfString[3] = "scroll";
    Cursor localCursor = localSQLiteDatabase.query("tbl_bookmark", arrayOfString, null, null, null, null, null);
    if ((localCursor != null) && (localCursor.getCount() != 0));
    for (int i = 0; ; i++)
    {
      if (i >= localCursor.getCount())
        return localArrayList;
      localCursor.moveToPosition(i);
      Bookmark localBookmark = new Bookmark();
      localBookmark.setId(localCursor.getInt(localCursor.getColumnIndex("id")));
      localBookmark.setName(localCursor.getString(localCursor.getColumnIndex("bookmark_name")));
      localBookmark.setChapterID(localCursor.getInt(localCursor.getColumnIndex("chapter_id")));
      localBookmark.setScroll(localCursor.getInt(localCursor.getColumnIndex("scroll")));
      localBookmark.setTime(localCursor.getLong(localCursor.getColumnIndex("time")));
      localArrayList.add(localBookmark);
    }
  }

  public long insertBookmark(Bookmark paramBookmark)
  {
    ContentValues localContentValues = new ContentValues();
    localContentValues.put("bookmark_name", paramBookmark.getName());
    localContentValues.put("chapter_id", Integer.valueOf(paramBookmark.getChapterID()));
    localContentValues.put("scroll", Integer.valueOf(paramBookmark.getScroll()));
    localContentValues.put("time", Long.valueOf(paramBookmark.getTime()));
    return this.db.insert("tbl_bookmark", null, localContentValues);
  }

  public void onCreate(SQLiteDatabase paramSQLiteDatabase)
  {
    paramSQLiteDatabase.execSQL("CREATE TABLE tbl_bookmark( id INTEGER PRIMARY KEY AUTOINCREMENT, bookmark_name TEXT NOT NULL, chapter_id INTEGER NOT NULL, scroll INTEGER NOT NULL, time INTEGER NOT NULL);");
  }

  public void onUpgrade(SQLiteDatabase paramSQLiteDatabase, int paramInt1, int paramInt2)
  {
    paramSQLiteDatabase.execSQL("DROP TABLE IF EXISTS tbl_bookmark");
    onCreate(paramSQLiteDatabase);
  }
}

/* Location:           C:\Users\chutieucodon\Desktop\dec\com.book.dacnhantam-36fb9c182ef79376b618c867d3d1c347\classes_dex2jar.jar
 * Qualified Name:     com.book.dacnhantam.data.DatabaseHelper
 * JD-Core Version:    0.6.0
 */